﻿@model List<XukaShop.Models.Entities.Message>

@{
    ViewBag.Title = "Index";
    Layout = "~/Areas/Admin/Views/Shared/_AdminLayout.cshtml";
}

@section Breadcrumbs
{
    <div class="media">
        <div class="pageicon pull-left">
            <i class="fa fa-home"></i>
        </div>
        <div class="media-body">
            <ul class="breadcrumb">
                <li><a href="@Url.Action("Index", "Dashboard")"><i class="glyphicon glyphicon-home"></i></a></li>
                <li><a href="@Url.Action("Index", "Dashboard")">Trang chủ</a></li>
            </ul>
            <h4>Danh sách tin nhắn</h4>
        </div>
    </div>
}

@section MenuBar
{
    <h5 class="leftpanel-title">Menu</h5>
    <ul class="nav nav-pills nav-stacked">
        <li><a href="@Url.Action("Index", "Dashboard")"><i class="fa fa-home"></i><span>Trang chủ</span></a></li>
        <li><a href="@Url.Action("Index", "Order")"><i class="glyphicon glyphicon-shopping-cart"></i><span>Đặt hàng</span></a></li>
        <li class="active"><a href="@Url.Action("Index", "Message")"><i class="glyphicon glyphicon-envelope"></i><span>Tin nhắn</span></a></li>
        <li class="parent"><a href="#"><i class="fa fa-file-text"></i><span>Sản phẩm</span></a>
            <ul class="children">
                <li><a href="@Url.Action("ProductList", "Product")">Tất cả sản phẩm</a></li>
                <li><a href="@Url.Action("NewProduct", "Product")">Sản phẩm mới</a></li>
                <li><a href="@Url.Action("CommingSoonProduct", "Product")">Sản phẩm sắp có</a></li>
                <li><a href="@Url.Action("Index", "Brand")">Nhãn hàng</a></li>
            </ul>
        </li>
        <li><a href="@Url.Action("Index", "Promotion")"><i class="glyphicon glyphicon-bullhorn"></i><span>Giảm giá</span></a></li>
        <li><a href="@Url.Action("MemberList", "Member")"><i class="glyphicon glyphicon-user"></i><span>Thành viên</span></a></li>
        <li class="parent"><a href="#"><i class="fa fa-file-text"></i><span>Quản lý chung</span></a>
            <ul class="children">
                <li><a href="@Url.Action("Index", "Banner")">Banners</a></li>
            </ul>
        </li>
    </ul>
}

@*<div class="panel panel-default-head">
    <div class="panel-heading">
        <h4 class="panel-title">Danh sách tin nhắn</h4>        
    </div>
    <!-- panel-heading -->

    <table id="messageTable" class="table table-striped table-bordered responsive">
        <thead class="">
            <tr>
                <th>Mã tin nhắn</th>
                <th>Ngày gửi</th>
                <th>Người gửi</th>
                <th>Số điện thoại</th>
                <th>Tình trạng</th>
                <th style="text-align: center">#</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var message in Model)
            {
                <tr>
                    <td>
                        @message.Id
                    </td>
                    <td>
                        @message.SendDate.ToString("dd/MM/yyyy")
                    </td>
                    <td>
                        @message.SenderName
                    </td>
                    <td>
                        @message.SenderPhoneNum
                    </td>
                    <td>
                        @message.IsRead
                    </td>
                    <td class="table-action">
                        <a href="@Url.Action("MessageDetail", "Message", new { messageId = message.Id })" data-toggle="tooltip" title="" class="tooltips" data-original-title="Sửa"><i class="fa fa-pencil"></i></a>
                        <a href="#" data-toggle="tooltip" title="" class="delete-row tooltips" id="delete_message_@message.Id" data-original-title="Xóa"><i class="fa fa-trash-o" onclick="deleteMessage('@message.Id')"></i></a>
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>*@

<div class="row">
    <div class="col-sm-3 col-md-3 col-lg-2">
        <div class="msg-header">
            <button class="btn btn-white tooltips" type="button" data-toggle="tooltip" title="Xóa tin nhắn"><i class="fa fa-trash-o"></i></button>
            <button class="btn btn-white tooltips" type="button" data-toggle="tooltip" title="Đánh dấu đã đọc"><i class="fa fa-tag"></i></button>
        </div>
        <ul class="nav nav-pills nav-stacked nav-msg">
            <li class="active">
                <a href="@Url.Action("Index", "Message")">
                    <span class="badge pull-right">2</span>
                    <i class="glyphicon glyphicon-inbox"></i>Hộp thư đến
                </a>
            </li>
            <li><a href="#"><i class="glyphicon glyphicon-send"></i>Thư đã gửi</a></li>
            <li><a href="#"><i class="glyphicon glyphicon-trash"></i>Thư đã xóa</a></li>
        </ul>
    </div>

    <div class="col-sm-9 col-md-9 col-lg-10">

        <div class="msg-header">
            <div class="pull-right">
                <button class="btn btn-white btn-navi btn-navi-left ml5" type="button"><i class="fa fa-chevron-left"></i></button>
                <button class="btn btn-white btn-navi btn-navi-right" type="button"><i class="fa fa-chevron-right"></i></button>

            </div>
            <!-- pull-right -->
        </div>
        <!-- msg-header -->

        <ul class="media-list msg-list">
            @foreach (var item in Model)
            {
                <li class="media">
                    <div class="ckbox ckbox-primary pull-left">
                        <input type="checkbox" id="checkbox_@Model.IndexOf(item)">
                        <label for="checkbox_@Model.IndexOf(item)"></label>
                    </div>
                    <a class="pull-left" href="@Url.Action("MessageDetail", "Message", new { messageId = item.Id})">
                        <img class="media-object img-circle img-online" src="~/Areas/Admin/images/photos/user1.png" alt="...">
                    </a>
                    <div class="media-body">
                        <div class="pull-right media-option">
                            <i class="fa fa-paperclip mr5"></i>
                            <small>@item.SendDate.ToString("dd/MM/yyyy hh:mm")</small>
                            <a href="#"><i class="fa fa-star"></i></a>
                            <div class="btn-group">
                                <a class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                    <i class="fa fa-cog"></i>
                                </a>
                                <ul class="dropdown-menu pull-right" role="menu">
                                    <li><a href="#">Mark as Unread</a></li>
                                    <li><a href="#">Reply</a></li>
                                    <li><a href="#">Delete</a></li>
                                </ul>
                            </div>
                        </div>
                        <h4 class="sender">Renov Leonga</h4>
                        <p><a href="@Url.Action("MessageDetail", "Message", new { messageId = item.Id})"><strong class="subject">Hi Hello!</strong> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt...</a></p>
                    </div>
                </li>
            }
        </ul>
    </div>
</div>

<script>
    //jQuery(document).ready(function () {
    //    jQuery('#messageTable').DataTable({
    //        responsive: true
    //    });
    //});

    jQuery(document).ready(function () {
        //highlight rows that are already checked
        jQuery('.msg-list .ckbox input').each(function () {
            if (jQuery(this).is(':checked')) {
                jQuery(this).parents('li').addClass('highlighted');
            }
        });

        // highlight/unhighlight rows when checked/unchecked
        jQuery('.ckbox input').click(function () {
            if (jQuery(this).is(':checked')) {
                jQuery(this).parents('li').addClass('highlighted');
            } else {
                jQuery(this).parents('li').removeClass('highlighted');
            }
        });
    });

    @* function showMessageDeleteSuccess() {
        jQuery.gritter.add({
            title: 'Thành công!',
            text: 'Xóa tin nhắn thành công!',
            class_name: 'growl-success',
            sticky: false,
            time: '1000'
        });
        return false;
    }

    function showMessageDeleteFail() {
        jQuery.gritter.add({
            title: 'Thất bại!',
            text: 'Xóa tin nhắn thất bại!',
            class_name: 'growl-danger',
            sticky: false,
            time: '1000'
        });
        return false;
    }

    function deletePromotion(orderCode) {
        bootbox.confirm("Bạn có muốn xóa tin nhắn này không?", function (result) {
            if (result) {
                $.ajax({
                    url: "@Url.Action("DeleteOrder", "Order")",
                    type: "POST",
                    data: { orderCode: orderCode },
                    success: function (result) {
                        if (result == "@XukaShop.Common.CommonConst.SUCCESSFUL") {
                            $('.close').click();
                            hideTableRow(promotionId);
                            showMessageDeleteSuccess();
                        }
                        if (result == "@XukaShop.Common.CommonConst.FAIL") {
                            showMessageDeleteFail();
                        }
                    }
                });
            }
        });
    }

    function hideTableRow(messageCode) {
        var rowId = "delete_message_" + messageCode;
        var tr = $("#" + rowId).closest('tr');
        tr.fadeOut(400, function () {
            tr.remove();
        });
        return false;
    }*@
</script>
